package com.njbdqn.ALi.zjg.Controller;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.njbdqn.ALi.zjg.entity.RecommendNeedRecord;
import com.njbdqn.ALi.zjg.services.RecommendNeedRecordService;
import com.xubao.ali.services.PrintWriterService;

/**
 * Servlet implementation class SaveRnrController
 */
public class SaveRnrController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private PrintWriterService out = new PrintWriterService();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		/*HttpSession session = request.getSession();
		Userinfos user = null;
		user = (Userinfos)session.getAttribute("user");*/
		
		String bind = request.getParameter("bind");
		String recommendbookname = request.getParameter("recommendbookname");
		String recommendbookvotenumber = request.getParameter("recommendbookvotenumber");
		
		int rbv = Integer.parseInt(recommendbookvotenumber);
		
		RecommendNeedRecord rnr = new RecommendNeedRecord();
		rnr.setBind(bind);
		rnr.setRecommendbookname(recommendbookname);
		rnr.setRecommendbookvotenumber(rbv);
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		
		try {
			rnr.setRecommendbooktime(sdf.parse(sdf.format(new Date())));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		new RecommendNeedRecordService().save(rnr);
		
		
	}

}
